package hang.study.uistudy;

import android.content.Context;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * Created by Administrator on 2015/7/7.
 */
public class TimeListAdapter extends ArrayAdapter<Long> {

    public TimeListAdapter(Context context, int textViewResourceId){
        super(context, textViewResourceId);
        Log.d(Util.LogTag,"构造TimeListAdapter");
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        if(view == null){
            Log.d(Util.LogTag,"List Adapter 中view为null");
            view = LayoutInflater.from(getContext()).inflate(R.layout.time_row,null);
        }else{
            Log.d(Util.LogTag,"List Adapter 中view不为null");
        }

        ((TextView)view.findViewById(R.id.lap_name)).setText(String.format(getContext().getResources().getString(R.string.task_name),position+1));
        ((TextView)view.findViewById(R.id.lap_time)).setText(DateUtils.formatElapsedTime(getItem(position)));

        return view;
    }
}
